import {useRef, useState} from "react";

//react中获取DOM 元素

// 1.useRef生成ref对象 绑定到dom标签身上
// 2.dom可用时,ref.current获取dom
 export  const App = () => {
    const myRef = useRef()
     const showDOM=()=>{
         console.dir(myRef.current)
     }
    return (
        <div>
            <input type="text" ref={myRef}/>
            <button onClick={showDOM}>获取dom</button>
        </div>
    )
}
